import api from '../utils/api';

export async function login(param) {
  return api.post('/login', {
    data: JSON.stringify(param),
  });
}

export async function enterAuth() {
  return api.post('/enterAuth');
}

export async function logout() {
  return api.post('/logout');
}

export async function roomCount() {
  return api.post('/roomCount');
}
export async function qryUcount() {
  return api.post('/qryUcount');
}
export async function qryAssetCount() {
  return api.post('/qryAssetCount');
}
export async function qryAlarmCount() {
  return api.post('/qryAlarmCount');
}
export async function qryPresetCount() {
  return api.post('/qryPresetCount');
}
export async function qryUPerByRoom() {
  return api.post('/qryUPerByRoom');
}
export async function qryScrapCount() {
  return api.post('/qryScrapCount');
}

export async function assetCountByRoom(param) {
  return api.post('/assetCountByRoom', {
    data: JSON.stringify(param),
  });
}

export async function editPassword(param) {
  return api.post('/sys/user/updatePass', {
    data: JSON.stringify(param),
  });
}
export function date2str(x,y) {
  var z = {
     y: x.getFullYear(),
     M: x.getMonth() + 1,
     d: x.getDate(),
     h: x.getHours(),
     m: x.getMinutes(),
     s: x.getSeconds()
  };
  return y.replace(/(y+|M+|d+|h+|m+|s+)/g, function(v) {
     return ((v.length > 1 ? "0" : "") + eval('z.' + v.slice(-1))).slice(-(v.length > 2 ? v.length : 2))
  });
}
export function replaceStr(x){
  return new Date(x.replace(/-/g,"/"));
}
